package com.health.db.dao.sm.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.sm.IDepartmentListDao;
import com.health.db.mapper.DepartmentListMapper;
import com.health.db.model.DepartmentList;
import com.health.db.model.DepartmentListExample;
import com.health.redis.RedisConstants;
 

@Component("departmentListDao")
public class DepartmentListDaoImpl extends ServiceInterface implements IDepartmentListDao  {
	
	@Autowired
	DepartmentListMapper departmentListMapper ;

	@Override
	public List<DepartmentList> selectByExample(DepartmentListExample example) {
		// TODO Auto-generated method stub
		return departmentListMapper.selectByExample(example);
	}

	@Override
	public DepartmentList selectByPrimaryKey(Long recid) {
		// TODO Auto-generated method stub
		return departmentListMapper.selectByPrimaryKey(recid);
	}

	@Override
	public List<DepartmentList> selectByAllRecord() {
		// TODO Auto-generated method stub
		
		getRedisOperatiorLogic();
	    String key =RedisConstants.NEWDepartmentListMapper+"ALL";
	    
	    Object object=null;
	    List<DepartmentList>  list = null;
      
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	 if (!object.equals("")) {
        		 list = ( List<DepartmentList> ) object;
			}
         }else{
        	 list= departmentListMapper.selectByAllRecord();
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));
             }
         }
        return list;
		
	}

	public DepartmentListMapper getDepartmentListMapper() {
		return departmentListMapper;
	}

	public void setDepartmentListMapper(DepartmentListMapper departmentListMapper) {
		this.departmentListMapper = departmentListMapper;
	}


	

	
}
